using JGSY.CMS.LowCode.Platform.Application.DTOs;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 页面应用服务接口
    /// 提供页面管理相关的业务逻辑操作
    /// </summary>
    public interface IPageAppService
    {
        /// <summary>
        /// 获取所有页面
        /// </summary>
        /// <returns>页面列表</returns>
        Task<IEnumerable<PageDto>> GetAllAsync();

        /// <summary>
        /// 根据ID获取页面
        /// </summary>
        /// <param name="id">页面ID</param>
        /// <returns>页面信息</returns>
        Task<PageDto?> GetByIdAsync(long id);

        /// <summary>
        /// 根据别名获取页面
        /// </summary>
        /// <param name="slug">页面别名</param>
        /// <returns>页面信息</returns>
        Task<PageDto?> GetBySlugAsync(string slug);

        /// <summary>
        /// 获取子页面列表
        /// </summary>
        /// <param name="parentId">父页面ID</param>
        /// <returns>子页面列表</returns>
        Task<IEnumerable<PageDto>> GetChildrenAsync(long parentId);

        /// <summary>
        /// 获取导航页面
        /// </summary>
        /// <returns>导航页面列表</returns>
        Task<IEnumerable<PageDto>> GetNavigationPagesAsync();

        /// <summary>
        /// 分页获取页面列表
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="keyword">搜索关键词</param>
        /// <param name="status">状态过滤</param>
        /// <returns>分页页面列表</returns>
        Task<(IEnumerable<PageDto> Items, int TotalCount)> GetPagedAsync(
            int pageIndex, 
            int pageSize, 
            string? keyword = null, 
            byte? status = null);

        /// <summary>
        /// 创建页面
        /// </summary>
        /// <param name="pageDto">页面信息</param>
        /// <returns>创建的页面</returns>
        Task<PageDto> CreateAsync(PageDto pageDto);

        /// <summary>
        /// 更新页面
        /// </summary>
        /// <param name="pageDto">页面信息</param>
        /// <returns>更新的页面</returns>
        Task<PageDto> UpdateAsync(PageDto pageDto);

        /// <summary>
        /// 删除页面
        /// </summary>
        /// <param name="id">页面ID</param>
        /// <returns>是否删除成功</returns>
        Task<bool> DeleteAsync(long id);

        /// <summary>
        /// 批量删除页面
        /// </summary>
        /// <param name="ids">页面ID列表</param>
        /// <returns>删除的数量</returns>
        Task<int> BatchDeleteAsync(IEnumerable<long> ids);

        /// <summary>
        /// 更新页面状态
        /// </summary>
        /// <param name="id">页面ID</param>
        /// <param name="status">状态</param>
        /// <returns>是否更新成功</returns>
        Task<bool> UpdateStatusAsync(long id, byte status);

        /// <summary>
        /// 增加页面访问量
        /// </summary>
        /// <param name="id">页面ID</param>
        /// <returns>是否更新成功</returns>
        Task<bool> IncrementViewCountAsync(long id);

        /// <summary>
        /// 检查页面别名是否存在
        /// </summary>
        /// <param name="slug">页面别名</param>
        /// <param name="excludeId">排除的页面ID</param>
        /// <returns>是否存在</returns>
        Task<bool> SlugExistsAsync(string slug, long? excludeId = null);

        /// <summary>
        /// 获取页面层级结构
        /// </summary>
        /// <returns>页面树形结构</returns>
        Task<IEnumerable<PageDto>> GetHierarchyAsync();
    }
}
